import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/ruoyi";


// 查询列表
export function listDingDan(query) {
  return request({
    url: '/system/dingDan/list',
    method: 'get',
    params: query
  })
}

// 查询列表
export function listByUserId(userId) {
  return request({
    url: '/system/dingDan/listByUserId',
    method: 'get',
    params: {
      userId
    }
  })
}

export function listDingDanHistory(userId, huoPinId, dataRange){
  let timeStart = null;
  let timeEnd = null;
  if(dataRange.length>1){
    timeStart = dataRange[0];
    timeEnd = dataRange[1];
  }
  return request({
    url: '/system/dingDan/listDingDanHistory',
    method: 'get',
    params: {
      userId,
      huoPinId,
      timeStart,
      timeEnd
    }
  })
}

// 查询详细
export function getDingDan(id) {
  return request({
    url: '/system/dingDan/' + parseStrEmpty(id),
    method: 'get'
  })
}


// 新增
export function save(data) {
  return request({
    url: '/system/dingDan',
    method: 'post',
    data: data
  })
}

// 审核
export function shenhe(id, status, remark) {
  return request({
    url: '/system/dingDan/shenhe',
    method: 'post',
    data: {
      id,status,statusReason: remark
    }
  })
}

// 审核
export function del(id) {
  return request({
    url: '/system/dingDan/'+id,
    method: 'delete',
    data: {
      id
    }
  })
}

// 审核
export function shangBao(id) {
  return request({
    url: '/system/dingDan/shangBao/'+id,
    method: 'get',
    data: {
      id
    }
  })
}


// 撤销
export function cheXiao(id) {
  return request({
    url: '/system/dingDan/cheXiao/'+id,
    method: 'get',
    data: {
      id
    }
  })
}


